package com.onpositive.image.fitting.tools;
import java.awt.Rectangle;
import java.awt.image.BufferedImage;

import com.onpositive.image.factories.AbstractImageFitter;
import com.onpositive.image.fitting.tools.TransformerFactory.TransformParam;


public class HalfShrinkingFitter extends AbstractImageFitter {

	@Override
	protected BufferedImage doFitImage(BufferedImage source, Rectangle destRect) {
		
		double srcWidth = source.getWidth() ;
		double dstWidth = destRect.getWidth() ;
		
		double srcHeight = source.getHeight();
		double dstHeight = destRect.getHeight() ;
		
		double xRatio = ( dstWidth  +1 ) / srcWidth  ;		
		double yRatio = ( dstHeight +1 ) / srcHeight ;
		
		boolean cutTo_X = xRatio < yRatio ;
		boolean cutTo_Y = !cutTo_X ;
		double ratio = cutTo_X ? xRatio : yRatio ;
		
		double epsilon = 0.0000001 ;
		
//		int widthScale =
//		for(   )

		TransformParam tp = TransformerFactory.getInstance().createRoughResizeParam(source, destRect, 1 ) ;
		BufferedImage result = new BufferedImage( tp.getDstWidth(), tp.getDstHeight(), source.getType() ) ;
		tp.getTransformOp().filter( source, result ) ;
		
		return null;
	}

}
